package cn.tool.dao.excel.write;

import cn.tool.dao.excel.read.FujinRead;
import cn.tool.dao.pojo.excelpojo.ExcelDepartment;
import cn.tool.dao.pojo.excelpojo.ExcelOrg;
import cn.tool.dao.pojo.excelpojo.ExcelUser;
import com.alibaba.excel.EasyExcel;

import java.util.List;

public class FujinWrite {
    //镇名
    String townName;
    private String userPath;
    private String orgPath;
    private String departmentPath;

    public FujinWrite(String townName) {
        this.townName = townName;
        this.userPath = "src/main/resources/file/fujinExecl/result/" + townName + "用户表.xlsx";
        this.orgPath = "src/main/resources/file/fujinExecl/result/" + townName + "经济组织表.xlsx";
        this.departmentPath = "src/main/resources/file/fujinExecl/result/" + townName + "部门表.xlsx";
    }

    public void exportUser(List<ExcelUser> excelUserList) {
        EasyExcel.write(userPath, ExcelUser.class).sheet().doWrite(excelUserList);
    }

    public void exportOrg(List<ExcelOrg> excelOrgList) {
        EasyExcel.write(orgPath, ExcelOrg.class).sheet().doWrite(excelOrgList);
    }

    public void exportDepartment(List<ExcelDepartment> excelDepartmentList) {
        EasyExcel.write(departmentPath, ExcelDepartment.class).sheet().doWrite(excelDepartmentList);
    }

    public static void main(String[] args) {
//        List<ExcelUser> excelUserList = FujinRead.getExcelUserList();
        FujinWrite write = new FujinWrite("测试镇");
//        write.exportUser(excelUserList);
        List<ExcelOrg> excelOrgList = FujinRead.getExcelOrgList();
        write.exportOrg(excelOrgList);
    }
}
